# -*- coding:utf-8 -*-
# @Time: 2020/9/24 21:32
# @Author: 周铖鑫
# @Description：主次坐标轴
# @File: primary&&secondary-Axies.py
import  matplotlib.pyplot as plt
import  numpy as np
x=np.arange(0,10,0.1)
y1=0.05*x**2
y2=-y1
fig,ax1=plt.subplots()
#twinx共享x轴，twiny共享y轴
ax2=ax1.twinx()
ax1.plot(x,y1,'g--')
ax2.plot(x,y2,'r--')
ax1.set_xlabel('x data')
ax1.set_ylabel('Y1',color='r')
ax2.set_ylabel('Y2',color='b')
plt.show()